package com.pocketsweet.model;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.avos.avoscloud.AVClassName;
import com.avos.avoscloud.AVObject;

@AVClassName("MLPaidVoip")
public class MLPaidVoip extends AVObject {
	public static String CUSTOMER = "customer";// 消费人
	public static String SERVER = "server";// 服务的人
	public static String ENDEDAT = "endedAt";// 结束时间
	public static String DURATION = "duration";// 服务时间
	public static String UNIT_PRICE = "unit_price";// 服务单价
	public static String TOTAL_PRICE = "total_price";// 服务总价

	public MLPaidVoip() {

	}

	// 消费的人（外键1:1）
	public MLUser getCustomer() {
		return (MLUser) super.getAVUser(CUSTOMER);
	}

	public void setCustomer(MLUser user) {
		super.put(CUSTOMER, user);
	}

	// 服务的人（外键1:1）
	public MLUser getServer() {
		return (MLUser) super.getAVUser(SERVER);
	}

	public void setServer(MLUser user) {
		super.put(SERVER, user);
	}

	// 结束的时间
	public String getEndedAtFromat() {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		return format.format(getEndedAt());
	}

	public void setEndedAt(Date value) {
		super.put(ENDEDAT, value);
	}

	public Date getEndedAt() {
		if (super.getDate(ENDEDAT) != null) {
			return super.getDate(ENDEDAT);
		} else {
			return new Date();
		}
	}

	// 服务时间
	public int getDuration() {
		return super.getInt(DURATION);
	}

	public void setDuration(int value) {
		super.put(DURATION, value);
	}

	// 服务单价
	public double getUnitPrice() {
		return super.getDouble(UNIT_PRICE);
	}

	public void setUnitPrice(double value) {
		super.put(UNIT_PRICE, value);
	}

	// 服务总价
	public double getTotalPrice() {
		return super.getDouble(TOTAL_PRICE);
	}

	public void setTotalPrice(double value) {
		super.put(TOTAL_PRICE, value);
	}
}
